﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TasksModel
{
    [System.Xml.Serialization.XmlInclude(typeof(GoogleCalendarSynchSettings))]
    [System.Xml.Serialization.XmlInclude(typeof(WebServiceSynchSettings))]
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://mp.tasks.com/2010/", IsNullable = false)]
    public class SynchSettings : IdentifiedObject
    {
        protected SynchSettings()
        {
        }

        private SynchDirection _mode;

        /// <summary>
        /// Current operation mode.
        /// </summary>
        public SynchDirection Mode
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return _mode; }
            set
            {
                if (_mode != value)
                {
                    _mode = value;
                    NotifyPropertyChanged("Mode");
                }
            }
        }

        #region Virtual

        /// <summary>
        /// True if configuration is complete (possible to use).
        /// </summary>
        public virtual bool IsConfigured { get { return false; } }

        /// <summary>
        /// Synchronization provider name.
        /// </summary>
        public virtual string ProviderName { get { return null; } }

        /// <summary>
        /// Support information.
        /// </summary>
        /// <param name="mode">mode to check</param>
        /// <returns>true if supported</returns>
        public virtual bool Supports(SynchDirection mode)
        {
            System.Diagnostics.Debug.Assert(mode != SynchDirection.None);
            return true;
        }

        #endregion

        /// <summary>
        /// Synchronization operation mode.
        /// </summary>
        public enum SynchDirection
        {
            None = 0,
            /// <summary>
            /// Merge
            /// </summary>
            TwoWay,
            /// <summary>
            /// Export
            /// </summary>
            ToExternalOnly,
            /// <summary>
            /// Import
            /// </summary>
            FromExternalOnly,
        }
    }
}